﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using log4net;

namespace Log4NetApplication
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void btnGeneratorLog_Click(object sender, EventArgs e)
        {
            btnGeneratorLog.Enabled = false;
            Random random = new Random();
            ILog infoLog = LogManager.GetLogger("Info");
            ILog errorLog = LogManager.GetLogger("Error");

            int count = 1000;
            int index=0;
            for (int i = 0; i < count; i++)
            {
                index = random.Next(DateTime.Now.Millisecond) % 5;
                switch (index)
                {
                    case 0: infoLog.Debug("Debug"); errorLog.Debug("Debug"); break;
                    case 1: infoLog.Info("Info"); errorLog.Info("Info"); break;
                    case 2: infoLog.Warn("Warn"); errorLog.Warn("Warn"); break;
                    case 3: infoLog.Error("Error"); errorLog.Error("Error"); break;
                    case 4: infoLog.Fatal("Fatal"); errorLog.Fatal("Fatal"); break;
                    default:
                        break;
                }
            }

            btnGeneratorLog.Enabled = true;
        }
    }
}
